Completed
Pull Request — master (#50)
by
unknown
01:55
created

regex.js ➔ describe(ꞌregexꞌ)   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 78

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 78
rs 8.9019
c 1
b 1
f 0

8 Functions

Rating   Name   Duplication   Size   Complexity  
A regex.js ➔ ... ➔ it(ꞌcmsData.regex.isEachStatement()ꞌ) 0 6 1
A regex.js ➔ ... ➔ it(ꞌcmsData.regex.getTagAbeTypeRequest()ꞌ) 0 6 1
A regex.js ➔ ... ➔ before 0 13 1
A regex.js ➔ ... ➔ it(ꞌcmsData.regex.isBlockAbe()ꞌ) 0 6 1
A regex.js ➔ ... ➔ it(ꞌcmsData.regex.escapeTextToRegex()ꞌ) 0 4 1
A regex.js ➔ ... ➔ it(ꞌcmsData.regex.isSingleAbe()ꞌ) 0 6 1
A regex.js ➔ ... ➔ it(ꞌcmsData.regex.validDataAbe()ꞌ) 0 3 1
A regex.js ➔ ... ➔ it(ꞌcmsData.regex.getAttr()ꞌ) 0 4 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
var chai = require('chai');
2
var path = require('path');
3
4
var config = require('../../../src/cli').config
5
config.set({root: path.join(process.cwd(), 'test', 'fixtures')})
6
7
var cmsData = require('../../../src/cli').cmsData
8
var Manager = require('../../../src/cli').Manager;
9
var fse = require('fs-extra');
10
11
describe('regex', function() {
12
  before( function(done) {
13
    Manager.instance.init()
14
      .then(function () {
15
16
        this.fixture = {
17
          articleSingle: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-single-abe.html'), 'utf8'),
18
          articleEach: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-each-abe.html'), 'utf8'),
19
          articleRequest: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-request.html'), 'utf8')
20
        }
21
        done()
22
        
23
      }.bind(this))
24
  });
25
26
  /**
27
   * cmsData.regex.getAttr
28
   */
29
  it('cmsData.regex.getAttr()', function() {
30
    var attribute = cmsData.regex.getAttr(this.fixture.articleSingle, 'key')
31
    chai.assert.equal(attribute, 'title');
32
  });
33
34
  /**
35
   * cmsData.regex.escapeTextToRegex
36
   */
37
  it('cmsData.regex.escapeTextToRegex()', function() {
38
    var attribute = cmsData.regex.escapeTextToRegex(this.fixture.articleSingle, 'g')
39
    chai.expect(typeof attribute).to.contain('object');
40
  });
41
42
  /**
43
   * cmsData.regex.isSingleAbe
44
   */
45
  it('cmsData.regex.isSingleAbe()', function() {
46
    var bool = cmsData.regex.isSingleAbe(this.fixture.articleSingle)
47
    chai.expect(bool).to.be.true;
0 ignored issues
show
introduced by
The result of the property access to chai.expect(bool).to.be.true is not used.
Loading history...
48
    bool = cmsData.regex.isSingleAbe(this.fixture.articleEach)
49
    chai.expect(bool).to.be.false;
0 ignored issues
show
introduced by
The result of the property access to chai.expect(bool).to.be.false is not used.
Loading history...
50
  });
51
52
  /**
53
   * cmsData.regex.isBlockAbe
54
   */
55
  it('cmsData.regex.isBlockAbe()', function() {
56
    var bool = cmsData.regex.isBlockAbe(this.fixture.articleSingle)
57
    chai.expect(bool).to.be.false;
0 ignored issues
show
introduced by
The result of the property access to chai.expect(bool).to.be.false is not used.
Loading history...
58
    bool = cmsData.regex.isBlockAbe(this.fixture.articleEach)
59
    chai.expect(bool).to.be.true;
0 ignored issues
show
introduced by
The result of the property access to chai.expect(bool).to.be.true is not used.
Loading history...
60
  });
61
62
  /**
63
   * cmsData.regex.isEachStatement
64
   */
65
  it('cmsData.regex.isEachStatement()', function() {
66
    var bool = cmsData.regex.isEachStatement(this.fixture.articleSingle)
67
    chai.expect(bool).to.be.false;
0 ignored issues
show
introduced by
The result of the property access to chai.expect(bool).to.be.false is not used.
Loading history...
68
    bool = cmsData.regex.isEachStatement(this.fixture.articleEach)
69
    chai.expect(bool).to.be.true;
0 ignored issues
show
introduced by
The result of the property access to chai.expect(bool).to.be.true is not used.
Loading history...
70
  });
71
72
  /**
73
   * cmsData.regex.getTagAbeTypeRequest
74
   */
75
  it('cmsData.regex.getTagAbeTypeRequest()', function() {
76
    var arr = cmsData.regex.getTagAbeTypeRequest(this.fixture.articleSingle)
77
    chai.expect(arr[0]).to.be.undefined;
0 ignored issues
show
introduced by
The result of the property access to chai.expect(arr.0).to.be.undefined is not used.
Loading history...
78
    var arr = cmsData.regex.getTagAbeTypeRequest(this.fixture.articleRequest)
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable arr already seems to be declared on line 76. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
79
    chai.expect(arr[0]).to.not.be.null;
0 ignored issues
show
introduced by
The result of the property access to chai.expect(arr.0).to.not.be.null is not used.
Loading history...
80
  });
81
82
  /**
83
   * cmsData.regex.validDataAbe
84
   */
85
  it('cmsData.regex.validDataAbe()', function() {
86
    // doesn't tested because not sure what it does
87
  });
88
});